Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: OpenDoc Cookbook / Part - Appendixes
Appendix A - OpenDoc Utilities


Window Utilities (WinUtils)

This section describes the utilities defined in the files WinUtils.h and WinUtils.cpp. When you're reopening a window at document-launch time, you can use these utilities to retrieve the window properties stored with the root frame of any persistently stored window.

Retrieving Window Properties

When a saved document is opened, OpenDoc retrieves the root frame of each saved window and calls the Open method of the part belonging to that frame, passing the frame. The part is responsible for recreating the platform window and creating an ODWindow object using the RegisterWindowForFrame method.

The properties of the window are saved in a storage unit referenced from the root frame. The utility functions BeginGetWindowProperties and EndGetWindowProperties can be used to retrieve these properties without using the storage system API directly.

Using the Window Utilities

The window utilities functions allow a part editor to obtain the properties necessary to create a window from the storage annotation on a root frame. The BeginGetWindowProperties function returns kODTrue if the annotation exists and fills in the properties structure. The EndGetWindProperties function releases the frame specified in the sourceFrame field of the structure.

The following code fragment illustrates use of the window utilities:

WindowProperties props;
ODWindow* window = kODNULL;

if (BeginGetWindowProperties(ev, frame, &props))
{

ODPlatformWindow platformWindow = 
NewCWindow(kODNULL, 
&(props.boundsRect), 
props.title, 
kODFalse, 
props.procID, 
(WindowPtr)-1L, 
props.hasCloseBox, 
props.refCon);

window =  fSession->GetWindowState(ev)->RegisterWindowForFrame(ev, platformWindow, 
frame,
props.isRootWindow,// keeps draft open
kODTrue,// is resizable
kODFalse,// is floating
kODTrue,// shouldSave
props.sourceFrame);
EndGetWindowProperties(ev, &props); // release source frame
}


Previous Book Contents Book Index Next

© Apple Computer, Inc.
16 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help